package com.ias.agdis_r.fragment.task;

import java.util.List;
import java.util.Map;

import android.os.Bundle;
//import android.support.v4.app.Fragment;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.ias.agdis_r.R;
import com.ias.agdis_r.adapter.TaskProcessAdapter;
import com.ias.agdis_r.db.BoxDBHelper;
import com.ias.agdis_r.module.MessageModel;

/**
 * 任务详情_任务进展页面
 * @author guoxr
 *
 */
public class TaskInfoTab02 extends Fragment {
	private ListView listview;
	private TaskProcessAdapter adapter;
	private List<Map<String, Object>> list;
	private String tnb;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.taskinfo_tab02, container, false);
		tnb = getArguments().getString(MessageModel.TNB);
		BoxDBHelper dbHelper = new BoxDBHelper(getActivity());
		list = dbHelper.getData(BoxDBHelper.TABLE_TASKPROCESS, new String[] {
				"_id", "title", "msg", "time" }, "tnb = '" + tnb + "'", "time desc");
		dbHelper.closeDB();
		adapter = new TaskProcessAdapter(getActivity(), list);
		listview = (ListView) view.findViewById(R.id.id_stickynavlayout_innerscrollview);
		listview.setAdapter(adapter);
		return view;
	}

	public void refresh() {
		if (list != null) {
			list.clear();
		}
		BoxDBHelper mHelper = new BoxDBHelper(getActivity());
		list.addAll(mHelper.getData(BoxDBHelper.TABLE_TASKPROCESS,
				new String[] { "_id", "title", "msg", "time" }, "tnb = '" + tnb + "'",
				"time desc"));
		mHelper.closeDB();
		adapter.notifyDataSetChanged();
	}
}
